/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pspackdescription;

import com.ps.packdescription.db.DBManager;
import com.ps.packdescription.excel.ExcelReader;
import com.ps.packdescription.excel.ExcelWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

/**
 *
 * @author srkrishnan
 */
public class PSPackDescription implements Runnable {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Thread mainth = new Thread(new PSPackDescription());
        mainth.start();

    }

    @Override
    public void run() {
        try {
            //connect with DB
            DBManager.connectDB();

            Configuration config = new PropertiesConfiguration("my.properties");

            if ("download".equals(config.getString("mode"))) {
                ExcelWriter.write();
            }

            if ("upload".equals(config.getString("mode"))) {
                ExcelReader.read();
            }
        } catch (ConfigurationException ex) {
            Logger.getLogger(PSPackDescription.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
